import 'package:flutter/material.dart';
import 'package:flutter_layout/app.dart';
import 'package:flutter_layout/base/routes.dart';
import 'package:get/get.dart';

import 'index.dart';

class RouteObservers extends NavigatorObserver {
  @override
  void didPush(Route route, Route? previousRoute) {
    logger.i("didPush-当前路由页: ${route.settings.name}");
    // super.didPush(route, previousRoute);
  }

  @override
  void didPop(Route route, Route? previousRoute) {
    logger.i("didPop-当前路由页: ${route.settings.name}");
    if (!App.homeStatus) {
      Get.toNamed(Routes.home);
    }
    super.didPop(route, previousRoute);
  }

  @override
  void didRemove(Route route, Route? previousRoute) {
    logger.i("didRemove-当前路由页: ${route.settings.name}");
    super.didRemove(route, previousRoute);
  }

  @override
  void didStartUserGesture(Route route, Route? previousRoute) {
    super.didStartUserGesture(route, previousRoute);
    logger.i("didStartUserGesture-当前路由页: ${route.settings.name}");
  }

  @override
  void didStopUserGesture() {
    logger.i("didStopUserGesture-当前路由页");
    super.didStopUserGesture();
  }
}
